package com.example.shopping_mall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.shopping_mall.R;
import com.example.shopping_mall.bean.SettlementAmountBean;

import java.util.List;

;

/*
* 结算页面适配器
* */

public class SettlementAmountAdapter extends RecyclerView.Adapter<SettlementAmountAdapter.MyHolder> {

    private Context context;

    public SettlementAmountAdapter(Context context) {
        this.context = context;
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    private List<SettlementAmountBean> list;




    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyHolder holder=new MyHolder( LayoutInflater.from( context )
                .inflate( R.layout.settlementmount,null ) );
        return holder;
    }


    @Override
    public void onBindViewHolder( MyHolder holder, int position) {
        holder.imageView.setImageResource( list.get( position ).getImage() );
        holder.t1.setText( list.get( position ).getShangpinname());
        holder.t2.setText( list.get( position ).getColor());
        holder.t3.setText( list.get( position ).getMoney());
        holder.t4.setText( list.get( position ).getShuzi());


    }

    @Override
    public int getItemCount() {
        return null==list ? 0 : list.size() ;
    }

    class MyHolder extends RecyclerView.ViewHolder{
        ImageView imageView;
        TextView t1;
        TextView t2;
        TextView t3;
        TextView t4;


        public MyHolder( View itemView) {
            super( itemView );

            imageView=itemView.findViewById( R.id.fill_btn );
            t1=itemView.findViewById( R.id.fill_text);
            t2=itemView.findViewById( R.id.fill_color );
            t3=itemView.findViewById( R.id.fill_money );
            t4=itemView.findViewById( R.id.shuzi_1 );

        }
    }
}
